<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="js/vue.js"></script>
    <script src="js/axios.js"></script>
    <style>
        *{
            margin: 0;
            padding: 0;

        }
        .tr{
            width: 600px;
        }
        .item{
            float: left;
            width: 100px;
            height: 40px;
            text-align: center;
            line-height: 40px;
            background-color: black;
            color: cadetblue;
        }

    </style>
</head>
<body>
    <div id="app">
        <div class="table">
            <div class="tr">
                <div class="item">全选</div>
                <div class="item">名称</div>
                <div class="item">价格</div>
                <div class="item">数量</div>
                <div class="item">小计</div>
                <div class="item">操作</div>
            </div>
            <div class="tr" v-for="item in  list">
                <div class="item"></div>
                <div class="item">{{item.goodsname}}</div>
                <div class="item">{{item.goodsprice}}</div>
                <div class="item">{{item.buynum}}</div>
                <div class="item">{{item.buynum*item.goodsprice}}</div>
                <div class="item">删除</div>
            </div>
        </div>
    </div>
</body>
<script>
    new  Vue({
        el:"#app",
        data:{
            list:[]
        },
        async created(){
            let  userinfo = window.localStorage.getItem("userinfo");
            if(userinfo){
                userinfo = JSON.parse(userinfo);
                let  {data:list} = await  axios({
                    method:"get",
                    url:"http://localhost:2345/shoppingcar",
                    params:{
                        userid:userinfo.id
                    }
                })
                this.list = list;

            }
        }
        
    })

</script>
</html>